<template>
  <AdminLayout active-menu="house-verification">
    <div class="house-verification-content">
      <div class="content-header">
        <h2>房源审核管理</h2>
        <p>审核和管理平台上的房源信息</p>
      </div>

      <!-- 搜索和筛选区域 -->
      <div class="search-filter-section">
        <el-card class="filter-card">
          <div class="search-section">
            <el-select
              v-model="searchType"
              placeholder="搜索条件"
              style="width: 120px; margin-right: 10px;"
              @change="updateSearchPlaceholder"
            >
              <el-option label="房产ID" value="propertyId"></el-option>
              <el-option label="房东ID" value="landlordId"></el-option>
              <el-option label="地址" value="address"></el-option>
              <el-option label="房产证编号" value="propertyNo"></el-option>
              <el-option label="全部" value="all"></el-option>
            </el-select>
            <el-input
              v-model="searchKeyword"
              :placeholder="searchPlaceholder"
              clearable
              style="width: 300px; margin-right: 15px;"
              @input="handleSearch"
            >
              <template #suffix>
                <el-icon><Search /></el-icon>
              </template>
            </el-input>
            <el-button type="primary" @click="handleSearch">搜索</el-button>
            <el-button type="info" @click="refreshData" :loading="loading">刷新数据</el-button>
          </div>

          <el-form :inline="true" :model="filterForm" class="filter-form">
            <el-form-item label="审核状态">
              <el-select v-model="filterForm.status" placeholder="选择状态" clearable @change="handleFilter">
                <el-option label="全部" value=""></el-option>
                <el-option label="待审核" value="0"></el-option>
                <el-option label="已通过" value="1"></el-option>
                <el-option label="已驳回" value="2"></el-option>
                <el-option label="已取消" value="3"></el-option>
              </el-select>
            </el-form-item>

            <el-form-item label="提交时间">
              <el-date-picker
                v-model="filterForm.dateRange"
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                @change="handleFilter"
              />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="handleFilter">筛选</el-button>
              <el-button @click="resetFilters">重置</el-button>
            </el-form-item>
          </el-form>
        </el-card>
      </div>

      <!-- 房源申请列表 -->
      <div class="house-list-section">
        <el-card class="list-card">
          <template #header>
            <div class="card-header">
              <span>房源申请列表 ({{ filteredHouses.length }})</span>
              <div class="header-actions">
                <el-button type="success" @click="batchApprove" :disabled="selectedHouses.length === 0">
                  批量通过 ({{ selectedHouses.length }})
                </el-button>
                <el-button type="danger" @click="batchReject" :disabled="selectedHouses.length === 0">
                  批量拒绝 ({{ selectedHouses.length }})
                </el-button>
              </div>
            </div>
          </template>

          <div class="table-container">
            <el-table
            :data="paginatedHouses"
            @selection-change="handleSelectionChange"
            style="width: 100%;"
            class="house-table"
            stripe
            v-loading="loading"
          >
            <el-table-column type="selection" width="55" />
            <el-table-column prop="propertyVerifyId" label="房产ID" width="80" />
            <el-table-column prop="userId" label="房东ID" width="80" />
            <el-table-column prop="propertyAddr" label="地址" width="180" />
            <el-table-column prop="propertyNo" label="房产证编号" width="140" />
            <el-table-column label="房产证图片" width="100">
              <template #default="scope">
                <div class="image-preview-cell">
                  <img
                    v-if="scope.row.propertyPicPath && isValidImageUrl(scope.row.propertyPicPath)"
                    :src="scope.row.propertyPicPath"
                    alt="房产证图片"
                    class="table-image-preview"
                    @click="previewImage(scope.row.propertyPicPath)"
                    @error="handleImageError"
                  />
                  <div v-else class="no-image-cell">
                    {{ scope.row.propertyPicPath ? '图片无效' : '暂无图片' }}
                  </div>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="applyTime" label="提交时间" width="150">
              <template #default="scope">
                {{ formatDateTime(scope.row.applyTime) }}
              </template>
            </el-table-column>
            <el-table-column prop="verifyStatus" label="状态" width="100">
              <template #default="scope">
                <el-tag
                    :type="scope.row.verifyStatus === 0 ? 'warning' :
                         scope.row.verifyStatus === 1 ? 'success' :
                         scope.row.verifyStatus === 2 ? 'danger' : 'info'">
                  {{ getStatusText(scope.row.verifyStatus) }}
                </el-tag>
              </template>
            </el-table-column>
            <el-table-column label="操作" width="260" fixed="right">
              <template #default="scope">
                <div class="action-buttons">
                  <el-button size="small" type="primary" @click="viewHouse(scope.row)">查看详情</el-button>
                  <el-button
                      v-if="scope.row.verifyStatus === 0"
                      size="small"
                      type="success"
                      @click="approveHouse(scope.row)"
                      :loading="approving"
                  >
                    通过
                  </el-button>
                  <el-button
                      v-if="scope.row.verifyStatus === 0"
                      size="small"
                      type="danger"
                      @click="rejectHouse(scope.row)"
                  >
                    拒绝
                  </el-button>
                </div>
              </template>
            </el-table-column>
          </el-table>
          </div>

          <!-- 分页 -->
          <div class="pagination-wrapper">
            <el-pagination
              v-model:current-page="currentPage"
              v-model:page-size="pageSize"
              :page-sizes="[10, 20, 50, 100]"
              :total="filteredHouses.length"
              layout="total, sizes, prev, pager, next, jumper"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
            />
          </div>
        </el-card>
      </div>

      <!-- 详情对话框 -->
      <el-dialog
        v-model="dialogVisible"
        title="房产认证详情"
        width="900px"
        top="5vh"
        center
        :modal="true"
        :close-on-click-modal="false"
        :append-to-body="true"
        :destroy-on-close="true"
        custom-class="house-detail-dialog"
      >
        <div v-if="currentHouse" class="house-details">
          <el-row :gutter="20">
            <el-col :span="12">
              <el-descriptions :column="1" border>
                <el-descriptions-item label="房产ID">{{ currentHouse.propertyVerifyId }}</el-descriptions-item>
                <el-descriptions-item label="房东ID">{{ currentHouse.userId }}</el-descriptions-item>
                <el-descriptions-item label="房产地址">{{ currentHouse.propertyAddr }}</el-descriptions-item>
                <el-descriptions-item label="房产证编号">{{ currentHouse.propertyNo }}</el-descriptions-item>
                <el-descriptions-item label="提交时间">{{ formatDateTime(currentHouse.applyTime) }}</el-descriptions-item>
                <el-descriptions-item label="状态">
                  <el-tag :type="currentHouse.verifyStatus === 0 ? 'warning' :
                               currentHouse.verifyStatus === 1 ? 'success' :
                               currentHouse.verifyStatus === 2 ? 'danger' : 'info'">
                    {{ getStatusText(currentHouse.verifyStatus) }}
                  </el-tag>
                </el-descriptions-item>
                <el-descriptions-item v-if="currentHouse.refuseReason" label="拒绝原因">
                  <span style="color: #f56c6c;">{{ currentHouse.refuseReason }}</span>
                </el-descriptions-item>
              </el-descriptions>
            </el-col>
            <el-col :span="12">
              <div class="property-certificate">
                <h4>房产证图片</h4>
                <div class="certificate-grid">
                  <img v-if="currentHouse.propertyPicPath && isValidImageUrl(currentHouse.propertyPicPath)"
                       :src="currentHouse.propertyPicPath"
                       alt="房产证图片"
                       class="certificate-image"
                       @click="previewImage(currentHouse.propertyPicPath)"
                       @error="handleImageError" />
                  <div v-else class="no-image">
                    {{ currentHouse.propertyPicPath ? '图片加载失败' : '暂无图片' }}
                  </div>
                </div>
              </div>
            </el-col>
          </el-row>
        </div>
        <template #footer>
          <el-button @click="dialogVisible = false">关闭</el-button>
          <el-button
            v-if="currentHouse && currentHouse.verifyStatus === 0"
            type="success"
            @click="approveHouse(currentHouse)"
            :loading="approving"
          >
            通过审核
          </el-button>
          <el-button
            v-if="currentHouse && currentHouse.verifyStatus === 0"
            type="danger"
            @click="showRejectDialog = true"
          >
            拒绝审核
          </el-button>
        </template>
      </el-dialog>

      <!-- 拒绝审核对话框 -->
      <el-dialog v-model="showRejectDialog" title="拒绝审核" width="500px">
        <el-form :model="rejectForm" label-width="80px">
          <el-form-item label="拒绝原因" required>
            <el-input
              v-model="rejectForm.reason"
              type="textarea"
              :rows="4"
              placeholder="请输入拒绝原因"
            />
          </el-form-item>
        </el-form>
        <template #footer>
          <el-button @click="showRejectDialog = false">取消</el-button>
          <el-button type="danger" @click="confirmReject">确认拒绝</el-button>
        </template>
      </el-dialog>
    </div>
  </AdminLayout>
</template>

<script setup>
import { ref, reactive, computed, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import AdminLayout from '@/components/layout/AdminLayout.vue'
import { Search } from '@element-plus/icons-vue'
import {
  getAllPropertyVerification,
  passPropertyVerify,
  batchPassPropertyVerify,
  rejectPropertyVerification
} from '@/utils/apiService'

// 搜索关键词
const searchKeyword = ref('')
const searchType = ref('all')
const searchPlaceholder = ref('搜索房产编号、地址、房东ID...')

// 筛选表单
const filterForm = reactive({
  status: '',
  dateRange: []
})

// 分页
const currentPage = ref(1)
const pageSize = ref(10)

// 对话框控制
const dialogVisible = ref(false)
const showRejectDialog = ref(false)
const currentHouse = ref(null)

// 选中的房源
const selectedHouses = ref([])

// 拒绝表单
const rejectForm = reactive({
  reason: ''
})

// 加载状态
const loading = ref(false)
const approving = ref(false)

// 房产认证数据
const houses = ref([])

// 筛选后的房源
const filteredHouses = computed(() => {
  let result = houses.value

  // 搜索过滤
  if (searchKeyword.value.trim()) {
    const keyword = searchKeyword.value.toLowerCase()

    switch (searchType.value) {
      case 'propertyId':
        result = result.filter(house => house.propertyId.toString().includes(keyword))
        break
      case 'landlordId':
        result = result.filter(house => house.userId.toString().includes(keyword))
        break
      case 'address':
        result = result.filter(house => house.propertyAddr.toLowerCase().includes(keyword))
        break
      case 'propertyNo':
        result = result.filter(house => house.propertyNo.toLowerCase().includes(keyword))
        break
      case 'all':
      default:
        result = result.filter(house =>
          house.propertyNo.toLowerCase().includes(keyword) ||
          house.userId.toString().includes(keyword) ||
          house.propertyAddr.toLowerCase().includes(keyword) ||
          house.propertyId.toString().includes(keyword)
        )
        break
    }
  }

  // 状态过滤
  if (filterForm.status !== '') {
    result = result.filter(house => house.verifyStatus.toString() === filterForm.status.toString())
  }

  // 时间过滤
  if (filterForm.dateRange && filterForm.dateRange.length === 2) {
    const [startDate, endDate] = filterForm.dateRange
    result = result.filter(house => {
      const applyTime = new Date(house.applyTime)
      return applyTime >= startDate && applyTime <= endDate
    })
  }

  return result
})

// 分页后的房源
const paginatedHouses = computed(() => {
  const start = (currentPage.value - 1) * pageSize.value
  const end = start + pageSize.value
  return filteredHouses.value.slice(start, end)
})

// 更新搜索框占位符
const updateSearchPlaceholder = () => {
  const placeholders = {
    'propertyId': '请输入房产ID...',
    'landlordId': '请输入房东ID...',
    'address': '请输入地址...',
    'propertyNo': '请输入房产证编号...',
    'all': '搜索房产编号、地址、房东ID...'
  }
  searchPlaceholder.value = placeholders[searchType.value] || placeholders['all']
}

// 搜索处理
const handleSearch = () => {
  currentPage.value = 1
}

// 筛选处理
const handleFilter = () => {
  currentPage.value = 1
}

// 重置筛选
const resetFilters = () => {
  Object.assign(filterForm, {
    status: '',
    dateRange: []
  })
  searchKeyword.value = ''
  handleFilter()
}

// 处理选择变化
const handleSelectionChange = (selection) => {
  selectedHouses.value = selection
}

// 分页处理
const handleSizeChange = (val) => {
  pageSize.value = val
  currentPage.value = 1
}

const handleCurrentChange = (val) => {
  currentPage.value = val
}

// 获取状态文本
const getStatusText = (status) => {
  const texts = {
    0: '待审核',
    1: '已通过',
    2: '已驳回',
    3: '已取消'
  }
  return texts[status] || status
}

// 格式化日期时间
const formatDateTime = (dateTime) => {
  if (!dateTime || dateTime === null) return '暂无时间'
  try {
    return new Date(dateTime).toLocaleString('zh-CN', {
      year: 'numeric',
      month: '2-digit',
      day: '2-digit',
      hour: '2-digit',
      minute: '2-digit',
      second: '2-digit'
    })
  } catch (error) {
    console.error('时间格式化错误:', error)
    return '时间格式错误'
  }
}

// 加载房产认证数据
const loadPropertyVerifications = async () => {
  loading.value = true
  try {
    console.log('开始获取房产认证数据...')

    // 调试：检查当前的token状态
    const adminToken = localStorage.getItem('adminToken')
    const userToken = localStorage.getItem('userToken')
    const isAdminLoggedIn = localStorage.getItem('isAdminLoggedIn')
    console.log('🔍 管理员token:', adminToken ? adminToken.substring(0, 8) + '...' : 'null')
    console.log('🔍 用户token:', userToken ? userToken.substring(0, 8) + '...' : 'null')
    console.log('🔍 管理员登录状态:', isAdminLoggedIn)

    const response = await getAllPropertyVerification()
    console.log('API响应:', response) // 调试日志

    // 检查响应是否成功 - 支持后端返回的 "200" 字符串格式
    if (response && response.data && (response.data.code === 1 || response.data.code === '1' || response.data.code === 200 || response.data.code === '200')) {
      houses.value = response.data.data || []
      console.log('成功获取数据:', houses.value)
      if (houses.value.length > 0) {
        ElMessage.success(`成功加载 ${houses.value.length} 条房产认证记录`)
      } else {
        ElMessage.info('暂无房产认证记录')
      }
    } else {
      console.log('API返回错误:', response)
      ElMessage.error(response?.data?.msg || response?.data?.message || '获取数据失败')
    }
  } catch (error) {
    console.error('获取房产认证数据失败:', error)
    ElMessage.error(`获取数据失败: ${error.message || '请稍后重试'}`)
  } finally {
    loading.value = false
  }
}



// 刷新数据
const refreshData = () => {
  loadPropertyVerifications()
}





// 查看房源详情
const viewHouse = (house) => {
  currentHouse.value = house
  dialogVisible.value = true
}

// 验证图片URL是否有效
const isValidImageUrl = (url) => {
  if (!url) return false
  const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp']
  const lowerUrl = url.toLowerCase()
  return imageExtensions.some(ext => lowerUrl.includes(ext)) || url.startsWith('data:image/')
}

// 图片预览
const previewImage = (imagePath) => {
  if (!imagePath) return
  // 创建图片预览对话框
  const imageDialog = document.createElement('div')
  imageDialog.style.cssText = `
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    cursor: pointer;
  `

  const img = document.createElement('img')
  img.src = imagePath
  img.style.cssText = `
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
  `

  imageDialog.appendChild(img)
  document.body.appendChild(imageDialog)

  // 点击关闭预览
  imageDialog.addEventListener('click', () => {
    document.body.removeChild(imageDialog)
  })
}

// 图片加载错误处理
const handleImageError = (event) => {
  event.target.style.display = 'none'
  const parent = event.target.parentElement
  if (parent) {
    parent.innerHTML = '<div class="no-image-cell">图片加载失败</div>'
  }
}



// 通过审核
const approveHouse = async (house) => {
  try {
    await ElMessageBox.confirm(`确定通过房产ID "${house.propertyVerifyId}" 的审核吗？`, '确认操作', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    })

    approving.value = true
    const response = await passPropertyVerify(house.propertyVerifyId)

    if (response && response.data && (response.data.code === 1 || response.data.code === '1' || response.data.code === 200 || response.data.code === '200')) {
      house.verifyStatus = 1
      ElMessage.success('房产认证审核已通过')
      dialogVisible.value = false
      // 刷新数据
      await loadPropertyVerifications()
    } else {
      ElMessage.error(response?.data?.msg || response?.data?.message || '操作失败')
    }
  } catch (error) {
    if (error !== 'cancel') {
      console.error('通过审核失败:', error)
      ElMessage.error('操作失败，请稍后重试')
    }
  } finally {
    approving.value = false
  }
}

// 拒绝审核
const rejectHouse = (house) => {
  currentHouse.value = house
  showRejectDialog.value = true
}

// 确认拒绝
const confirmReject = async () => {
  if (!rejectForm.reason.trim()) {
    ElMessage.warning('请输入拒绝原因')
    return
  }

  try {
    const response = await rejectPropertyVerification(currentHouse.value.propertyVerifyId, rejectForm.reason)

    if (response && response.data && (response.data.code === 1 || response.data.code === '1' || response.data.code === 200 || response.data.code === '200')) {
      currentHouse.value.verifyStatus = 2
      currentHouse.value.refuseReason = rejectForm.reason
      ElMessage.success('房产认证审核已拒绝')
      showRejectDialog.value = false
      dialogVisible.value = false
      rejectForm.reason = ''
      // 刷新数据
      await loadPropertyVerifications()
    } else {
      ElMessage.error(response?.data?.msg || response?.data?.message || '操作失败')
    }
  } catch (error) {
    console.error('拒绝审核失败:', error)
    ElMessage.error('操作失败，请稍后重试')
  }
}

// 批量通过
const batchApprove = async () => {
  const pendingHouses = selectedHouses.value.filter(house => house.verifyStatus === 0)
  if (pendingHouses.length === 0) {
    ElMessage.warning('没有可通过的房产认证')
    return
  }

  try {
    await ElMessageBox.confirm(`确定批量通过选中的 ${pendingHouses.length} 个房产认证吗？`, '确认操作', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    })

    const propertyVerifyIds = pendingHouses.map(house => house.propertyVerifyId)
    const response = await batchPassPropertyVerify(propertyVerifyIds)

    if (response && response.data && (response.data.code === 1 || response.data.code === '1' || response.data.code === 200 || response.data.code === '200')) {
      ElMessage.success(`成功通过 ${pendingHouses.length} 个房产认证`)
      selectedHouses.value = []
      // 刷新数据
      await loadPropertyVerifications()
    } else {
      ElMessage.error(response?.data?.msg || response?.data?.message || '批量操作失败')
    }
  } catch (error) {
    if (error !== 'cancel') {
      console.error('批量通过失败:', error)
      ElMessage.error('批量操作失败，请稍后重试')
    }
  }
}

// 批量拒绝
const batchReject = async () => {
  const pendingHouses = selectedHouses.value.filter(house => house.verifyStatus === 0)
  if (pendingHouses.length === 0) {
    ElMessage.warning('没有可拒绝的房产认证')
    return
  }

  try {
    const reason = await ElMessageBox.prompt('请输入拒绝原因', '批量拒绝', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      inputPattern: /.+/,
      inputErrorMessage: '拒绝原因不能为空'
    })

    // 批量拒绝需要逐个调用API（因为后端没有批量拒绝接口）
    const promises = pendingHouses.map(house =>
      rejectPropertyVerification(house.propertyVerifyId, reason.value)
    )

    await Promise.all(promises)
    ElMessage.success(`成功拒绝 ${pendingHouses.length} 个房产认证`)
    selectedHouses.value = []
    // 刷新数据
    await loadPropertyVerifications()
  } catch (error) {
    if (error !== 'cancel') {
      console.error('批量拒绝失败:', error)
      ElMessage.error('批量操作失败，请稍后重试')
    }
  }
}

// 组件挂载时加载数据
onMounted(async () => {
  // 检查管理员token和登录状态
  const adminToken = localStorage.getItem('adminToken')
  const userToken = localStorage.getItem('userToken')
  const isAdminLoggedIn = localStorage.getItem('isAdminLoggedIn')

  console.log('🔍 页面挂载时的状态检查:')
  console.log('  - 管理员token:', adminToken ? adminToken.substring(0, 8) + '...' : 'null')
  console.log('  - 用户token:', userToken ? userToken.substring(0, 8) + '...' : 'null')
  console.log('  - 管理员登录状态:', isAdminLoggedIn)

  // 检查登录状态
  const { checkLoginStatus } = await import('@/utils/auth')
  const status = checkLoginStatus()
  console.log('🔍 详细登录状态:', status)

  if (!adminToken) {
    ElMessage.warning('未找到管理员登录token，请先登录')
    return
  }

  if (isAdminLoggedIn !== 'true') {
    ElMessage.warning('管理员登录状态异常，请重新登录')
    return
  }

  loadPropertyVerifications()
})
</script>

<style scoped>
.house-verification-content {
  height: 100%;
  overflow-y: auto;
  padding: 20px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 10px;
  margin: 10px;
  box-shadow: 0 4px 20px rgba(0, 195, 255, 0.1);
}

.house-verification-content::-webkit-scrollbar {
  width: 8px;
}

.house-verification-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.house-verification-content::-webkit-scrollbar-thumb {
  background: rgba(0, 195, 255, 0.6);
  border-radius: 4px;
}

.house-verification-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 195, 255, 0.8);
}

.content-header {
  text-align: center;
  margin-bottom: 30px;
}

.content-header h2 {
  color: #2c3e50;
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 10px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.content-header p {
  color: #7f8c8d;
  font-size: 16px;
  margin: 0;
}

/* 搜索筛选区域 */
.search-filter-section {
  margin-bottom: 20px;
}

.filter-card {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 195, 255, 0.3);
  box-shadow: 0 4px 12px rgba(0, 195, 255, 0.1);
}

.search-section {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}

.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: end;
}

/* 列表区域 */
.house-list-section {
  margin-bottom: 20px;
}

.list-card {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 195, 255, 0.3);
  box-shadow: 0 4px 12px rgba(0, 195, 255, 0.1);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: #2c3e50;
}

.header-actions {
  display: flex;
  gap: 10px;
}

/* 表格样式 */
.house-table {
  background: transparent;
}

.house-table :deep(.el-table__header th) {
  background: rgba(0, 195, 255, 0.15) !important;
  color: #2c3e50 !important;
  font-weight: 600;
  border-bottom: 2px solid rgba(0, 195, 255, 0.3);
}

.house-table :deep(.el-table__row) {
  background: rgba(255, 255, 255, 0.9) !important;
}

.house-table :deep(.el-table__row:hover) {
  background: rgba(0, 195, 255, 0.1) !important;
}

.house-table :deep(.el-table__row--striped) {
  background: rgba(248, 249, 250, 0.9) !important;
}

.house-table :deep(.el-table__row--striped:hover) {
  background: rgba(0, 195, 255, 0.1) !important;
}

.pagination-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

/* 详情样式 */
.house-details {
  margin: 20px 0;
}

.property-certificate h4,
.property-description h4 {
  color: #2c3e50;
  margin-bottom: 15px;
  font-size: 16px;
  font-weight: 600;
}

.certificate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.certificate-image {
  width: 100%;
  height: 320px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid rgba(0, 195, 255, 0.3);
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.certificate-image:hover {
  border-color: rgba(0, 195, 255, 0.6);
  transform: scale(1.02);
  box-shadow: 0 6px 20px rgba(0, 195, 255, 0.2);
  cursor: pointer;
}

.no-image {
  width: 100%;
  height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 249, 250, 0.8);
  border: 2px dashed rgba(0, 195, 255, 0.3);
  border-radius: 8px;
  color: #999;
  font-size: 14px;
}

/* 表格容器样式 */
.table-container {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid #ebeef5;
}

/* 表格中的图片预览样式 */
.image-preview-cell {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 60px;
}

.table-image-preview {
  width: 80px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #ddd;
  cursor: pointer;
  transition: all 0.3s ease;
}

.table-image-preview:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.no-image-cell {
  color: #999;
  font-size: 12px;
  text-align: center;
  padding: 5px;
  background: #f5f5f5;
  border-radius: 4px;
  width: 80px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}



.property-description {
  margin-top: 20px;
  padding: 15px;
  background: rgba(248, 249, 250, 0.8);
  border-radius: 8px;
  border-left: 4px solid #00c3ff;
}

.property-description p {
  margin: 0;
  line-height: 1.6;
  color: #555;
}

/* 对话框样式 */
.el-dialog {
  margin: 0 auto !important;
  position: relative !important;
}

.el-dialog__wrapper {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* 房产详情对话框样式 */
.house-detail-dialog {
  min-height: 600px;
}

.house-detail-dialog .el-dialog__body {
  padding: 20px 20px 40px 20px !important;
  min-height: 450px;
}

.house-detail-dialog .property-certificate {
  margin-bottom: 30px;
}

.house-detail-dialog .certificate-grid {
  margin-bottom: 20px;
}

/* 操作按钮样式 */
.action-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
}

.action-buttons .el-button {
  margin: 0;
  white-space: nowrap;
}

.house-details {
  max-height: 70vh;
  overflow-y: auto;
}

/* 表格容器样式 */
.table-container {
  overflow-x: auto;
  min-width: 100%;
}

.house-table {
  min-width: 1200px;
}

/* 操作按钮样式 */
.house-table .el-button {
  margin-right: 8px;
  margin-bottom: 4px;
}

/* 搜索区域样式 */
.search-section {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.search-section .el-select,
.search-section .el-input {
  flex-shrink: 0;
}

/* 响应式设计 */
@media (max-width: 992px) {
  .search-section {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .search-section .el-select,
  .search-section .el-input {
    width: 100% !important;
  }

  .filter-form {
    flex-direction: column;
  }

  .filter-form .el-form-item {
    width: 100%;
  }

  .card-header {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }

  .header-actions {
    justify-content: center;
  }

  .image-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
}

@media (max-width: 768px) {
  .house-verification-content {
    padding: 15px;
    margin: 5px;
  }

  .content-header h2 {
    font-size: 24px;
  }

  .image-grid {
    grid-template-columns: 1fr 1fr;
  }
}
</style>
